const rulesDao = require("../dao/rulesDao");

exports.getList = async (req, res) => {
  const rules = await rulesDao.getAll();
  res.json(rules);
};

exports.add = async (req, res) => {
  const rule = req.body;
  const result = await rulesDao.add(rule);
  res.json({ code: 200, message: "添加成功", rule: result });
};

exports.update = async (req, res) => {
  const { id } = req.params;
  const rule = req.body;
  const result = await rulesDao.update(id, rule);
  res.json({ code: 200, message: "更新成功", rule: result });
};

exports.remove = async (req, res) => {
  const { id } = req.params;
  await rulesDao.remove(id);
  res.json({ code: 200, message: "删除成功" });
};
